#ifndef __CORE_H__
#define __CORE_H__

#include <string>
#include <vector>

using namespace std;
using std::string;
using std::vector;

enum MODE
{
    STRETCH = 0,
    CENTRE  = 1,
    TITLE   = 2,
    MODE_END
};

enum ORDER
{
    PRE = 0,
    NEXT = 1,
    RAND = 2,
    ORDER_END
};

class core
{
public:
    ~core();
    bool wallpaper_path(const char* path);
    bool load_wallpaper();
    bool change_time(unsigned long time);  
    bool pre_wallpaper();
    bool next_wallpaper();
    bool rand_wallpaper();
    void save_setting();
    void load_setting();
    void test();
public:
    static core& get()
    {
        return _obj;
    }
    
    inline void auto_start(bool bstart)
    {
        _auto_start = bstart;
    }

    inline const char* error() const
    {
        return _err_msg.c_str();
    }
    
    inline void wallpaper_pos(MODE pos)
    {
        _mode = pos;
    }
    
    inline const char* wallpaper_path()
    {
        return _wallpaper_path.c_str();
    }

    inline int wallpaper_pos()
    {
        return (int)_mode;
    }

    inline unsigned long change_time()
    {
        return _time;
    }

    inline bool auto_start()
    {
        return _auto_start;
    }

    inline int wallpaper_order()
    {
        return _order;
    }

    inline void wallpaper_order(ORDER order)
    {
        _order = order;
    }

private:
    core();
    void _find_files(const char* path);
    bool _set_wallpaper(const char* file);
    bool _reg_autostart();

    static core         _obj;
    vector<string>      _vec_wallpaper;
    string              _wallpaper_path;
    string              _err_msg;
    MODE                _mode;
    unsigned long       _time;
    bool                _recursion;
    bool                _auto_start;
    int                 _cur_index;
    ORDER               _order;   
};

#endif